package com.yunquan.ohana.utils

import android.view.View

// 处理View的快速点击出现的并发问题
fun preventQuickClick(view: View) {
    view.isClickable = false
    view.isEnabled = false
    view.postDelayed(
        {
            view.isClickable = true
            view.isEnabled = true
        }, 500
    )
}

fun setOnClickListener(listener: View.OnClickListener, vararg views: View) {
    val clickListener = View.OnClickListener {
        preventQuickClick(it)
        listener.onClick(it)
    }
    views.forEach {
        it.setOnClickListener(clickListener)
    }
}